<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
		<script type="text/javascript" src="../js/angular.js" ></script>
    </head>
    <body ng-app="myApp">
        <div ng-controller="MyCtrl">
     <table class="table">
         <thead>
             <tr>
                 <th>
                     <input type="checkbox" ng-click="selectAll($event)" ng-checked="isSelectedAll()"/>
                 </th>
                 <th>全选</th>
             </tr>
         </thead>
         <tbody>
             <tr ng-repeat="e in users" ng-class="getSelectedClass(e.id)">
                 <td>
                     <input type="checkbox" name="selected" ng-checked="isSelected(e.id)" ng-click="updateSelection($event, e.id)"/>
                 </td>
                 <td>{{e.name}}</td>
             </tr>
             <p>id{{selected}}</p>
             <p>姓名{{selected1}}</p>
             <p>帐号{{selected2}}</p>
             <button ng-click="ck()">点我</button>
         </tbody>
     </table>
 </div>
 <script>
     var myApp = angular.module('myApp', []);
 	myApp.controller('MyCtrl',function ($scope,$http) {
     $scope.users=[{
        "id": "1",
        "code": "123",
        "name": "qweww",
        "email": "70ee6533@qq.com"
      },
      {
        "id": "2",
        "code": "130",
        "name": "xueeen",
        "email": "70ee533@qq.com"
      },{
        "id": "3",
        "code": "1233",
        "name": "qwe1",
        "email": "707116533@qq.com"
      },
      {
        "id": "4",
        "code": "13230",
        "name": "xueq3uan",
        "email": "707116533@qq.com"
      }];
     $scope.ck = function(){
         if($scope.selected.length == 0){
             alert("空")
         }else{
             alert("非空")
         }
     }
     $scope.selected = [];
     var updateSelected = function (action, id ,name) {
         if (action == 'add' & $scope.selected.indexOf(id) == -1) $scope.selected.push(id);
         if (action == 'remove' && $scope.selected.indexOf(id) != -1) $scope.selected.splice($scope.selected.indexOf(id), 1);
     }


     $scope.updateSelection = function ($event, id) {
         var checkbox = $event.target;
         var action = (checkbox.checked ? 'add' : 'remove');
         updateSelected(action, id);
     };


     $scope.selectAll = function ($event) {
         var checkbox = $event.target;
         var action = (checkbox.checked ? 'add' : 'remove');
         for (var i = 0; i < $scope.users.length; i++) {
             var entity = $scope.users[i];
             updateSelected(action, entity.id);
         }
     };


     $scope.getSelectedClass = function (entity) {
         return $scope.isSelected(entity.id) ? 'selected' : '';
     };


     $scope.isSelected = function (id) {
         return $scope.selected.indexOf(id) >= 0;
     };

     $scope.isSelectedAll = function () {
         return $scope.selected.length === $scope.users.length;
     };
 }
)
 </script>
    </body>
</html>